package com.ymatou.i.accounting.api.service;

import org.json.JSONException;
import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.Logger;
import com.ymttest.utils.EnvSetup;
/**
*批量获取账户余额接口Call
*FreeMaker Template自动生成代码
*/
public class GetAccountBalanceListCall extends YmatouBaseCall{
	private static String opurl ="api/Account/GetAccountBalanceList";
	
	public GetAccountBalanceListCall() {
		super(EnvSetup.getSystemUrl("api_accounting"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	//获取 accountid
	public String getAccountId() {
		String cid = null;
		try {
			cid = new JSONObject(getReturnData()).getJSONObject("Data").getString("AccountId");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return cid;
	}
	
	//获取 Status
	public int getStatus() {
		int status = 0;
		try {
			status = new JSONObject(getReturnData()).getInt("StatusCode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return status;
	}
	
	//获取 data
	public JSONObject getData() {
		JSONObject data = null;
		try {
			data = new JSONObject(getReturnData()).getJSONObject("Data");
		} catch (JSONException e) {
			Logger.debug("GetAccountBalanceCall return data is null!");
		}
		return data;
	}
	
	//获取 msg
	public String getMsg() {
		String msg = null;
		try {
			msg = new JSONObject(getReturnData()).getString("Message");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return msg;
	}
	//获取 AvailAmount
	public String getAvailAmount() {
		String availAmount = null;
		try {
			availAmount = getData().getString("AvailAmount");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return availAmount;
	}
	//获取 FreezeAmount
	public String getFreezeAmount() {
		String freezeAmount = null;
		try {
			freezeAmount = getData().getString("FreezeAmount");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return freezeAmount;
	}
}